<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
<title>Insert title here</title>
<meta charset="UTF-8">
<base th:href="@{/}" />
<script src="js/jquery-3.4.1.min.js"></script>
<script src="js/bootstrap.min.js"></script>
<link rel="stylesheet" href="css/bootstrap.min.css" />
<link rel="stylesheet" href="css/Managerstyle.css" />

</head>
<body>
	<div class="contain">
		<h3>查看评教结果</h3>
		请输入要查询的学期：
		<select id="selectTyear" style="width: 150px">
			<option value="">请选择年份</option>
			<option th:each="year:${yearList}" th:value="${year}" th:text="${year}"></option>
		</select>
		<select id="selectTid" style="width: 150px">
			<option value="">请选择学期</option>
		</select>
		<input type="hidden" id="tid" th:value="${session.loginTeacher.tid}">
		<button id="select" type="button" >查询</button>
		
		<table class="table">
			<tr >
				<td>教师名称</td>
				<td>学期</td>
				<td>总分</td>
			</tr>
			<tbody id="result"></tbody>
		</table>
	</div>
	<script>
		$(document).ready(function(){
			

			$("#selectTyear").change(function(){
				var str = "<option value=''>请选择年份</option>";
				$.ajax({
					url: "teach/selectTermByTyear",
					type: "GET",
					data: {tyear: $("#selectTyear").val()},
					success: function(data){
						$("#selectTid").empty();
						$.each(data, function(index,value){
							var str1 = "<option value='" + value.termId + "'>" + value.termName + "</option>";
							$("#selectTid").append(str1);
						});
					},
					error: function(req, status, error)	{
						$("#selectTid").empty();
						$("#selectTid").append(str);
					}
				});
			});
			
			$("#select").click(function(){
				$.ajax({
					url: "teach/getAssessResult",
					type: "GET",
					data: {tid: $("#tid").val(), termId : $("#selectTid").val()},
					success: function(data){
						$("#result").empty();
						var str = "<tr>" + "<td>" + data.teacher.tname + "</td>" +
						"<td>" + data.term.termName + "</td>" +
						"<td>" + data.assessResult + "</td>" +
						"</tr>";
						$("#result").append(str);
					},
					error: function(){
						
					}
				});
				
			});
			
			
		});
	
	</script>
	
</body>
</html>